package com.niit.factory;

/**
 * @author hanli
 * @date 2025/3/4
 * @description TODO
 */
public class TestFactory {
    public static void main(String[] args) {

        // 向上转型
        Phone phone1 = new XiaoMiPhone();
        Phone phone2 = new HuaiWeiPhone();
        // return phon
        // 还原  向下转型
        XiaoMiPhone xiaoMiPhone = (XiaoMiPhone)phone1;
        //--------------------------------------------------------------------
        PhoneFactory factory = new PhoneFactory();

        Phone xiaomiPhone = factory.getPhone("XM");
        xiaomiPhone.call();

        Phone huaweiPhone = factory.getPhone("HW");
        huaweiPhone.call();

    }
}